<%@ page import="service.serviceimpl.ServiceImpl" %><%--
  Created by IntelliJ IDEA.
  User: Root404
  Date: 2023/5/15
  Time: 14:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--//三层思想  1）数据访问  2业务逻辑 3 页面展示--%>
<%
    //request.setCharacterEncoding("utf-8");//一定要放在前面
    String name = request.getParameter("name");
    //name=new String(name .getBytes("ISO-8859-1"), "UTF-8");
    String pwd = request.getParameter("pwd");
    ServiceImpl service = new ServiceImpl();
    //注册
    int load = service.load("select count(1) from t163 where name=? and pwd=?", name, pwd);
    if(load>0){
        session.setAttribute("user",name);
        session.setMaxInactiveInterval(60);
        //cookie--本地缓存 用来保存用户信息的--只能往后走
        Cookie user = new Cookie("user", name);
        response.addCookie(user);//加入本地缓存
        user.setMaxAge(60);
        //转发去成功页面，带值
        request.getRequestDispatcher("main.jsp?xxx=yy").forward(request,response);

    }else{
        //重定向回去登录页
        response.sendRedirect("login.jsp?isloading=false");
    }
%>

</body>
</html>
